#include <stdio.h>
#include <stdlib.h>
#include "uthread.h"

void fat(void *arg);

int main(int arch, char *argv[])
{
    int i,th[50],nThreads=10;
    libuthread_init();
	for(i=0;i<nThreads;i++)
	{
	    th[i] = uthread_create((void (*)(void))fat, &th[i]);

	}


	uthread_join(th[0]);
	exit(0);
}

void fat(void *arg)
{
    umutex_t lock[1];
    lock[0].busy=0;

    int th = (*(int*)arg);
	int i=5;


	while(i>0)
	{

	    uthread_lock(lock);
	    printf("thread %d\n",th);

	    uthread_yield();
	    i--;
	}
}
